package com.mcarthur.countdown.client.drawable;

public class Vector2 {
	public float x;
	public float y;
	
	Vector2() {
		x = 0;
		y = 0;
	}
	
	public Vector2(float x, float y) {
		this.x = x;
		this.y = y;
	}
	
	public Vector2 getUnit() {
		float magnitude = getMagnitude();
		return new Vector2(x / magnitude, y / magnitude);
	}
	
	public float dot(Vector2 vector) {
		return (x*vector.x) + (y*vector.y);
	}
	
	public Vector2 sub(Vector2 v) {
		return new Vector2(x - v.x, y - v.y);
	}
	
	public Vector2 add(Vector2 v) {
		return new Vector2(x + v.x, y + v.y);
	}
	
	public float getMagnitude() {
		return (float)Math.sqrt((x*x) + (y*y));
	}
	
	public Vector2 mult(float constant) {
		return new Vector2(x * constant, y * constant);
	}
}
